<template>
  <div class="publish-container">
    <el-form label-position="right"
             label-width="80px"
             ref="announcementForm"
             :model="AnnouncementForm">
      <el-form-item label="公告标题"
                    prop="title">
        <el-input style="width:200px"
                  v-model="AnnouncementForm.title"></el-input>
      </el-form-item>
      <el-form-item label="公告内容"
                    prop="content">
        <el-input type="textarea"
                  style="width:800px"
                  :rows="20"
                  v-model="AnnouncementForm.content"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="warning"
                   @click="publishAnnouncement">发布公告</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  props: {

  },
  components: {

  },
  data () {
    return {
      AnnouncementForm: {
        title: "",
        content: ""
      }
    };
  },
  computed: {

  },
  watch: {

  },
  created () {

  },
  mounted () {

  },
  methods: {
    // 发送公告
    async publishAnnouncement () {
      // 整理数据
      const datas = this.$qs.stringify(this.AnnouncementForm)
      const res = await this.$API.announcement.publishAnnouncement(datas)
      if (res.status == 200) {
        this.$message.success('发布成功')
        this.AnnouncementForm = {}
      } else {
        this.$message.error('发布失败')
      }
    },
  },
};
</script>

<style scoped>
.publish-container {
  margin: 20px;
}
</style>
